package sort.impl;

import anaydis.sort.SorterType;
import com.sun.istack.internal.NotNull;

import java.util.Comparator;
import java.util.List;

public class QuickSorter extends AbstractQuickSorter {

    public QuickSorter() {
        super(SorterType.QUICK);
    }

    public <T> void sort(@NotNull Comparator<T> comparator, @NotNull List<T> list) {
        sort(comparator, list, 0, list.size() - 1);
    }

    private <T> void sort(Comparator<T> comparator, List<T> list, int left, int right) {
        if (right <= left) return;
        int i = partition(comparator, list, left, right);
        sort(comparator, list, left, i - 1);
        sort(comparator, list, i, right);
    }

}






